package com.wenhui.schoolyardinfo.mine.presenter;

import android.content.Context;

import com.wenhui.schoolyardinfo.login.presenter.base.BasePresenter;
import com.wenhui.schoolyardinfo.login.view.base.IBaseView;
import com.wenhui.schoolyardinfo.mine.model.MineModelImpl;
import com.wenhui.schoolyardinfo.mine.model.base.IMineModel;
import com.wenhui.schoolyardinfo.mine.presenter.base.IMinePresenter;
import com.wenhui.schoolyardinfo.mine.view.IAuthenticationDataView;
import com.wenhui.schoolyardinfo.mine.view.IMineAlbumView;
import com.wenhui.schoolyardinfo.mine.view.IMineView;
import com.wenhui.schoolyardinfo.mine.view.IPersonalDataView;

import java.util.Map;

/**
 * author    : Urasaki
 * e-mail    : 1164688204@qq.com
 * date      : 2019/7/9 17:04
 * introduce : Presenter登录模块的（一个小模块对应一个Presenter）
 */

public class MinePresenterImpl extends BasePresenter<IBaseView> implements IMinePresenter {

    private static final String TAG = "MinePresenterImpl";
    //    private IMineView mineView;//P需要与V 交互，所以需要持有V的引用
    private IMineModel mineModel;

    public MinePresenterImpl(Context context, IBaseView baseView) {
        attachView(baseView);
        mineModel = new MineModelImpl(context);
    }

    @Override
    public void getMineData(Map<String, String> bodyParams) {
        if (getView() != null) {
            if (getView() instanceof IMineView) {
                final IMineView mineView = (IMineView) getView();
                mineView.showLoading();
//                mineModel.getMineData(bodyParams, new OnMineListener() {
//                    @Override
//                    public void onGetMineDataSuccess(String success) {
//                        mineView.getMineDataSuccess(success);
//                        mineView.hideLoading();
//                    }
//
//                    @Override
//                    public void onGetMineDataError(String error) {
//                        mineView.getMineDataError(error);
//                        mineView.hideLoading();
//                    }
//                });
            }
        }
    }

    @Override
    public void getPersonalData(Map<String, String> bodyParams) {
        if (getView() != null) {
            if (getView() instanceof IPersonalDataView) {
                final IPersonalDataView personalDataView = (IPersonalDataView) getView();
                personalDataView.showLoading();
//                mineModel.getPersonalData(bodyParams, new OnPersonalDataListener() {
//                    @Override
//                    public void onGetPersonalDataSuccess(String success) {
//                        personalDataView.getPersonalDataSuccess(success);
//                        personalDataView.hideLoading();
//                    }
//
//                    @Override
//                    public void onGetPersonalDataError(String error) {
//                        personalDataView.getPersonalDataError(error);
//                        personalDataView.hideLoading();
//                    }
//                });
            }
        }
    }

    @Override
    public void getMineAlbum(Map<String, String> bodyParams) {
        if (getView() != null) {
            if (getView() instanceof IMineAlbumView) {
                final IMineAlbumView mineAlbumView = (IMineAlbumView) getView();
                mineAlbumView.showLoading();
//                mineModel.getMineAlbum(bodyParams, new OnMineAlbumListener() {
//                    @Override
//                    public void onGetMineAlbumSuccess(String success) {
//                        mineAlbumView.getMineAlbumSuccess(success);
//                        mineAlbumView.hideLoading();
//                    }
//
//                    @Override
//                    public void onGetMineAlbumError(String error) {
//                        mineAlbumView.getMineAlbumError(error);
//                        mineAlbumView.hideLoading();
//                    }
//                });
            }
        }
    }

    @Override
    public void getAuthenticationData(Map<String, String> bodyParams) {
        if (getView() != null) {
            if (getView() instanceof IAuthenticationDataView) {
                final IAuthenticationDataView authenticationDataView = (IAuthenticationDataView) getView();
                authenticationDataView.showLoading();
//                mineModel.getAuthenticationData(bodyParams, new OnAuthenticationDataListener() {
//                    @Override
//                    public void onGetAuthenticationDataSuccess(String success) {
//                        authenticationDataView.getAuthenticationDataSuccess(success);
//                        authenticationDataView.hideLoading();
//                    }
//
//                    @Override
//                    public void onGetAuthenticationDataError(String error) {
//                        authenticationDataView.getAuthenticationDataError(error);
//                        authenticationDataView.hideLoading();
//                    }
//                });
            }
        }
    }

}
